linux_note
Debug grub and linux source code with GDB
Knowledge of assembly, shell, C are needed
work space
[email protected]:jindian/linux_startup.git
Both GRUB2 and linux source code included in above repository, file create_grub2_boot_disk_img.sh is used to create bootable disk image.
guide of debug with gdb
About how to compile grub2 and linux source code, create bootable disk image etc, read the instructions in README of linux_startup repository
debug GRUB2
- start qemu simulator: qemu-system-i386 -s -S disk.img disk.img is created with shell script create_grub2_boot_disk_img.sh
- in directory grub-2.00/grub-core, start gdb: gdb -x gdb_grub gdb_grub is a gdb source file, in which we define useful routines used in gdb and configure command executed after gdb startup
- set break point, for example at the entry of master boot record: break *0x7c00
- press 'c' to continue
- ...
debug linux
- the first step is same with debug GRUB2
- in directory linux start gdb: gdb -x gdb_linux
- in gdb_linux the first break point at start_kernel already set, set other break points as you want
- press 'c' to continue
- ...
Links
- x86 instruction
- x86 Assembly
- x86 Registers
- Extended Asm
- The GNU Assembler
- Debugging Assembly Code with gdb
- The BIOS/MBR Boot Process
- GRUB bootloader - Full tutorial
- OS Creation
- BIOS interrupt call
- Intel 80386 Reference
- GNU GRUB 2 Debugging with GDB
- THE LINUX/x86 BOOT PROTOCOL
- Debugging The Linux Kernel Using Gdb
- X86 Opcode and Instruction Reference
- LINUX SYSTEM CALL TABLE FOR X86 64
- i386 system calls
- Demystifying the Kernel Bootstrap Process
- Linux Kernel Debugging And Profiling Tools